<include file="public@agent_header"/>
</head>
<body>
<div class="wrap">
    <form class="well form-inline margin-top-20" method="post" action="">
        {$role.name}
        |
        工作状态：
        <select class="form-control" name="working">
            <option value="0" <if $role.working == 0>selected</if> >休假</option>
            <option value="1" <if $role.working == 1>selected</if> >空闲</option>
            <option value="2" <if $role.working == 2>selected</if> >工作中</option>
        </select>
        <input type="button" class="btn btn-primary grab_orders" value="自助申请"/>
        <input type="button" class="btn btn-success grab_orders" value="系统派单"/>
    </form>
    <ul class="nav nav-tabs">
        <li class="active"><a>订单列表</a></li>
    </ul>
    <form class="well form-inline margin-top-20" method="post" action="{:url('pc/customer_service/index')}">
        关键字：
        <input class="form-control" type="text" name="keyword" style="width: 200px;" value="{:input('request.keyword')}" placeholder="">
        <input type="submit" class="btn btn-primary" value="搜索"/>
        <a class="btn btn-danger" href="{:url('pc/customer_service/index')}">清空</a>
    </form>
    <form method="post" class="js-ajax-form">
        <table class="table table-hover table-bordered">
            <thead>
            <tr>
                <th>订单号</th>
                <th>销售组织</th>
                <th>订单类型</th>
                <th>销售类型</th>
                <th>销售人员</th>
                <th>客户</th>
                <th>发货组织</th>
                <th>收货方式</th>
                <th>支付方式</th>
                <th>支付账期</th>
                <th>发货日期</th>
                <th>总重量</th>
                <th>总价</th>
                <th>下单时间</th>
                <th>状态</th>
                <th>操作</th>
            </tr>
            </thead>
            <tbody>
            <php>
                $status_list = ['-1'=>'已拒绝','1'=>'待处理','2'=>'已处理'];
                $sale_type_text = ['1'=>'直销','2'=>'经销'];
            </php>
                <foreach name="list" item="vo">
                <tr>
                    <td>{$vo.order_no}</td>
                    <td>{:factory_name($vo.sale_number)}</td>
                    <td><if $vo.yushou_id>预售单转<else/>正常单</if></td>
                    <td>{$sale_type_text[$vo.sale_type]}</td>
                    <td>{$vo.staff_name}({$vo.staff_number})</td>
                    <td>{$vo.customer_name}({$vo.customer_number})</td>
                    <td>{$vo.factory_name}</td>
                    <td><if $vo.type == '自提'>{$vo.type}<else/>{$vo.receiving_address}</if></td>
                    <td>{$vo.pay_type}</td>
                    <td>{$vo.pay_account}</td>
                    <td>{$vo.fahuo_date}</td>
                    <td>{$vo.total_weight}</td>
                    <td>{$vo.total_price}</td>
                    <td>{$vo.create_time}</td>
                    <td>{$status_list[$vo.status]}</td>
                    <td>
                        <a class="btn btn-xs btn-primary" href="javascript:parent.openIframeLayer('{:url('index/details',array('id'=>$vo['id']))}','详情',{'area':['600px','80%']});">详情</a>
                        <a class="btn btn-xs btn-primary" href="javascript:parent.openIframeLayer('{:url('customer_service/edit',array('id'=>$vo['id']))}','详情',{'area':['800px','80%']});">编辑</a>
                        <a class="btn btn-xs btn-primary" href="">合同下载</a>
                        <a class="btn btn-xs btn-primary" href="javascript:parent.openIframeLayer('{:url('customer_service/contract_upload',array('id'=>$vo['id']))}','详情',{'area':['600px','80%']});">合同回传</a>
                        <a class="btn btn-xs btn-primary" href="javascript:parent.openIframeLayer('{:url('customer_service/power_upload',array('id'=>$vo['id']))}','详情',{'area':['600px','80%']});">上传委托书</a>
                    </td>
                </tr>
                </foreach>
            </tbody>
        </table>
        <div class="pagination">{$page}</div>
    </form>
</div>
<script src="__STATIC__/js/admin.js"></script>
<script src="__STATIC__/layui/layui.js"></script>
<script type="text/javascript">
$('select[name=working]').change(function(){
    var working = $(this).val();
    console.log(working);
    $.ajax({
        type: 'post',
        url: '{:url("customer_service/working")}',
        data: {working:working},
        success:function(res){

        }
    });
});

layui.use(['layer'],function(){
    var layer = layui.layer;

    $('.grab_orders').click(function(){
        $.ajax({
            type: 'get',
            url: '{:url("customer_service/grab_orders")}',
            success:function(res){
                if(res.code == 1){
                    layer.open({
                        type: 2,
                        title: '订单处理',
                        area: ['600px','80%'],
                        content: '{:url("customer_service/grab_orders")}'
                    });
                }else{
                    layer.msg(res.msg);
                }
            }
        })
    });
});

</script>
</body>
</html>